package com.properties;

import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import java.util.Properties;

import org.junit.Test;

public class PropertiesDemo {
	
	public static void testWrite() throws FileNotFoundException, IOException {
		Properties properties=new Properties();
		properties.setProperty("user", "admin");
		properties.setProperty("pass", "12346");
		
		properties.store(new FileOutputStream("settings.ini"), "setting");
	}
	private static void testRead() throws FileNotFoundException, IOException {
		
		Properties properties=new Properties();
		properties.load(new FileInputStream("settings.ini"));
		
		//2.
		System.out.println(properties.getProperty("username"));
		System.out.println(properties.getProperty("password"));
	}
@Test
public void testP() {
	try {
		testWrite();
	} catch (IOException e) {
		// TODO Auto-generated catch block
		e.printStackTrace();
	}
	try {
		testRead();
	} catch (IOException e) {
		// TODO Auto-generated catch block
		e.printStackTrace();
	}
}
}
